{template 'header-company'}
<!--当前位置-->
<div class="location layout960">
	当前位置: <a href="{SITE_URL}">首页</a>&nbsp;»&nbsp; <a href="{url('company/index')}">企业库</a>
</div>
<!--当前位置 end-->
<div class="main layout960">
	<form id="createdocForm" name="baike-form" method="post" class="jqeditor">
		{if $did}<input type="hidden" name='id' id="companyId" value="{$did}"/>{/if}
		{if $id}<input type="hidden" id="companyId" name='id' value="{$id}"/>{/if}

		<input type="hidden" id='author'  value="{$_username}"/>
		<input type="hidden" name='title' value="{$title}"/>
		<input type="hidden" name="category" value="{$category}"/>
		<div id="editoring" class="bd editor-box">
			<h2>您正在编辑：{$title}</h2>
		</div>
		<table class="company-info-tb">
			<tr><th>企业分类：</th><td><input id="chooseCat" type="button" value="选择/修改"/>请为您要创建的词条选择一个合适的分类。</td></tr>
			<tr>
				<th>已选分类：</th>
				<td>
					<ul id="selectedCats" class="fn-clear" name="select">
						{loop $cates $t}
						<li id="{$t}" class="fn-left fn-clear mr5">
							<span class="fn-left">{CategoryModule::getCacheCategoryName(25,$t)}</span>
							<a href="javascript:void(0);" title="删除此项" class="del fn-left"></a>
						</li>
						{/loop}
					</ul>
					<select name="cates[]" multiple="multiple" id="cates" size="2" style="display: none;">
						{loop $cates $t}
						<option id="{$t}" value="{$t}" selected="selected">{CategoryModule::getCacheCategoryName(25,$t)}</option>
						{/loop}
					</select>
				</td>
			</tr>
			<tr>
				<th width="90">公司LOGO：</th>
				<td>{Post::picture(2, 'thumb', 'com_thumb', $company_thumb ,500, 500)}</td>
			</tr>
			<tr>
				<th><span class="cred mr5">*</span>公司类型：</th>
				<td>{Post::select($types, 'com_type', $company_type)}</td>
			</tr>
			<tr>
				<th><span class="cred mr5">*</span>公司规模：</th>
				<td>{Post::select($sizes, 'com_size', $company_size)}</td>
			</tr>
			<tr>
				<th><span class="cred mr5">*</span>注册年份：</th>
				<td><input type="text" size="6" name="com_year" id="com_year" value="{$company_year}"/></td>
			</tr>
			<tr>
				<th><span class="cred mr5">*</span>注册资本：</th>
				<td>{Post::select($moneys, 'com_unit', $company_unit, $com_unit, '', 0)} <input type="text" size="6" name="com_money" id="com_money" value="{$company_money}"/> 万</td>
			</tr>
			<tr>
				<th><span class="cred mr5">*</span>公司所在地：</th>
				<td>{Post::areaCombo('com_areaid', $company_areaid)}</td>
			</tr>
			<tr>
				<th><span class="cred mr5"></span>详细地址：</th>
				<td><input type="text" size="20" name="com_address"  value="{$company_address}"/></td>
			</tr>
			<tr>
				<th><span class="cred mr5"></span>联系人：</th>
				<td><input type="text" size="11" name="com_contact"  value="{$company_contact}"/></td>
			</tr>
			<tr>
				<th><span class="cred mr5"></span>联系电话：</th>
				<td><input type="text" size="11" name="com_telephone"  value="{$company_telephone}"/></td>
			</tr>
			<tr>
				<th><span class="cred mr5"></span>邮箱：</th>
				<td><input class="easyui-validatebox" data-options="validType:'email'" type="text" size="20" name="com_mail"  value="{$company_mail}"/></td>
			</tr>
		</table>
		<div id="summary" class="bd editor-box">
			<h2>企业简介</h2>
			<div><textarea rows="3" class="size easyui-validatebox" name='summary' data-options="required:true,missingMessage:'请填写摘要'">{$summary}</textarea></div>
		</div>
		<div id="text" class="bd editor-box">
			<h2>详细介绍</h2>
            <div class="cat-list fn-clear">
	            {loop $defaultDoc $k $v}
                <div id="cat{$k}" class="defaultCat cat-item fn-left fn-clear">
                    <a class="jsCatOper add-cat fn-left" href="#" title="添加类目" onclick="return false"></a>
                    <a class="goto-cat fn-left" href="#" onclick="return false">{$v}</a>
                </div>
				{/loop}
                <div class="add-new fn-left">
                    <input id="add-new-ipt" type="text" value="输入新类目名称" size="15">
                    <button type="button" id="add-new-btn">添加</button>
                </div>
            </div>
            <input id="curEditId" type="hidden" value="" >
            <textarea id="editor" name="content" style="visibility:hidden;">{$content}</textarea>
            <input id="editorParam" type="hidden" value="25,1,xddlmaster,1,1">
		</div>


		<div id="reason" class="bd editor-box">
			<h2>修改原因<span class="red">[必填]</span></h2>
			<div>
				<label><input type="radio" value="全文编辑" checked="checked" name="reason"/>全文编辑</label>
				<label><input type="radio" value="新增内容" name="reason"/>新增内容</label>
				<label><input type="radio" value="修正错误" name="reason"/>修正错误</label>
				<label><input type="radio" value="新增图片" name="reason"/>新增图片</label>
				<label><input type="radio" value="设置目录" name="reason"/>设置目录</label>
				<label><input type="radio" value="增加内链" name="reason"/>增加内链</label>
				<label><input type="radio" value="调整页面" name="reason"/>调整页面</label>
			</div>
		</div>
		<div class="pushbutton">
			{if $type=='admin'}
				<input name="editAdminSubmit" class="conserve" type="submit" value="发布"/>
			{elseif $submitType}
				<input name="editSubmit" class="conserve" type="submit" value="发布"/>
			{else}
				<input name="createSubmit" class="conserve" type="submit" value="发布"/>
			{/if}
			<input id="abort-edit" type="button" value="退出"/>
		</div>
	</form>
</div>
<!--企业分类 对话框 start-->
<div style="display: none">
    <div id="companyCat" title="选择分类" class="easyui-dialog" style="padding:10px;" data-options="closed:'true'">
        <div class="company-cat">
            {Ext::categoryHtml(CompanyEntry::cateCateTree())}
        </div>
    </div>
</div>
<!--企业分类 对话框 start-->
<script type="text/javascript">
    seajs.use(['mod-catSelection','$','easyui','easyui-css','easyui-icon-css'], function (CatSel,$) {
        var catSel = new CatSel('chooseCat','companyCat','selectedCats','cates');
        catSel.run();
        $.extend($.fn.validatebox.defaults.rules, {
            fixLength: {
                validator: function(value, param){
                    return value.length == param[0]&& $.isNumeric(value);
                },
                message: '请输入{0}位数年份'
            },
            comMoney:{
                validator: function(value, param){
                    return $.isNumeric(value) && value>param[0];
                },
                message: '请输入大于0的注册资本'
            },
            comSize:{
                validator: function(value){
                    return $.isNumeric(value);
                },
                message: '请选择公司规模'
            },
            comType:{
                validator: function(value){
                    return $.isNumeric(value);
                },
                message: '请选择公司类型'
            },
            mobileType:{
                validator:function(value){
                    var mobileReg = /^(\+86)?(1[0-9]{10})$/,
                        telReg = /^d{3}(-)?d{8}|d{4}(-)?d{7,8}$/;
                    return mobileReg.test(value) || telReg.test(value)
                },
                message: '请填写11位手机号码或者是带有区号的电话号码！'
            }
        });
        $("#com_year").validatebox({
            required:true,
            validType:['fixLength[4]'],
            missingMessage:'请填写注册年份'
        });
        $('select[name="com_type"]').validatebox({
            required:true,
            missingMessage:'请选择企业类型'
        });
        $('#com_money').validatebox({
            required:true,
            validType:['comMoney[0]'],
            missingMessage:'请填写注册资金'
        });
        $('select[name="com_size"]').validatebox({
            required:true,
            validType:['comSize'],
            missingMessage:'请选择公司规模'
        });
        $('select[name="com_type"]').validatebox({
            required:true,
            validType:['comType'],
            missingMessage:'选择公司类型'
        });
        $("input[name='com_telephone']").validatebox({
            validType:['mobileType']
        });
        $('#createdocForm').submit(function(){
            if($(this).form('validate')){
                clearInterval(editor.draftTimer);
                return true;
            }else{
                return false;
            }
        });
    });
    seajs.use(['mod-editor'],function(Editor){
        var comEditor = new Editor("#editor"),eParam = $("#editorParam").val();
        comEditor.init(eParam);
        comEditor.run();
    });
</script>
<!--主体部分 end-->
{template 'footer'}